<?php

/**
 * Description of Mailer
 *
 * @author Remi
 */
class Mailer
{

    private $mailer_host = "smtp.gmail.com"; //smtp oO
    private $mailer_port = 587;
    private $mailer_fromName = "Plateforme des stages - Miage";
    private $mailer_from = "stage.miage.nice@gmail.com";
    private $mailer_username = "stage.miage.nice@gmail.com";
    private $mailer_password = "miageprojet2011";
    private $mailer_addReplyTo = "";
    public $myMailer;

    public function __construct()
    {
        $this->myMailer = new PHPMailer();
        $this->myMailer->IsSMTP();                    // set mailer to use SMTP
        $this->myMailer->Host = $this->mailer_host;    // specify main and backup server
        $this->myMailer->SMTPAuth = true;       // turn on SMTP authentication
        $this->myMailer->SMTPSecure = 'tls';    // enable TLS
        $this->myMailer->Username = $this->mailer_username;   // SMTP username
        $this->myMailer->Password = $this->mailer_password;   // SMTP password
        $this->myMailer->Port = $this->mailer_port;
        $this->myMailer->From = $this->mailer_from;
        $this->myMailer->FromName = $this->mailer_fromName;
        $this->myMailer->AddReplyTo($this->mailer_addReplyTo);
        $this->myMailer->WordWrap = 50;    // set word wrap to 50 characters
        $this->myMailer->IsHTML(true);
    }

    public function sendTest()
    {
        $this->myMailer->AddAddress("remi.heens@gmail.com", "MIAGE-PA");
        $this->myMailer->Subject = "TEST";
        $this->myMailer->Body = "TEST DU MAILER";
        $this->myMailer->AltBody = "TEST DU MAILER";
        return($this->myMailer->Send());
    }

    public function sendErreur($msg)
    {
        $this->myMailer->AddAddress($this->mailer_from, "MIAGE-PA");
        $this->myMailer->Subject = "Erreur";
        $this->myMailer->Body = $msg;
        $this->myMailer->AltBody = $msg;
        return($this->myMailer->Send());
    }
}

?>
